﻿#nullable disable
using Microsoft.AspNetCore.Mvc;
using Web.Controllers.Filter;

namespace Web.Controllers
{
    /// <summary>
    /// 基类
    /// </summary>
#if !DEBUG
    [CustomOAuth(null,"/oauth2/UserInfoCallback", OAuthScope.snsapi_userinfo)]//微信普通授权过滤器，OAuthScope.snsapi_userinfo方式授权
#endif
    public class Base2Controller : Controller
    {
        #region 变量与属性
        /// <summary>
        /// 公众号appId
        /// </summary>
        public string appId
        {
            get
            {
                return CoreHelper.AppSettingsManager.Get("SenparcWeixinSetting:WeixinAppId"); 
            }
        }

        /// <summary>
        /// 域名
        /// </summary>
        public string DomainUrl
        {
            get {
                return CoreHelper.AppSettingsManager.Get("basesetting:DomainUrl");
            }
        }
        /// <summary>
        /// 当前用户openid
        /// </summary>
        public string CurrentUserOpenid
        {
            get
            {
#if DEBUG
                //本地测试时使用
                string openid = CoreHelper.AppSettingsManager.Get("basesetting:testOpenid");
#else
                string openid = User.Identity.Name;
#endif
                return openid;
            }
        }
        #endregion

    }
}